<div class="row"> <h3 class="page-header">教职工列表</h3></div>
<div class="row">
    <div class="panel panel-default">
        <div class="panel-body">
            <label><a class="btn btn-primary addText" data-id='{$list.id}'>添加</a></label>
            <form action='{:U("Admins/index")}' class="form-inline text-right m-b-5 fr">
                姓名：<input type="text" name='name' value='{$Think.get.name}' class="form-control mr20 w150">
                &nbsp;&nbsp;
                工号：<input type="text" name='gh' value='{$Think.get.gh}' class="form-control mr20 w150">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <br><br>
                实验室：<select name='sysxx_id' class="form-control mr20 w120">
                <option value='-1'>全部</option>
                <volist name="sysxxList" id="_sysxx">
                    <option value='{$_sysxx.id}' <eq name='Think.get.sysxx_id' value="$_sysxx.id">selected</eq>>{$_sysxx.name}</option>
                </volist>
                </select>
                &nbsp;&nbsp;教研室：<select name='dep_id' class="form-control mr20 w200">
                <option value='-1'>全部</option>
                <volist name="depList" id="_dep">
                    <option value='{$_dep.id}' <eq name='Think.get.dep_id' value="$_dep.id">selected</eq>><for start = "1" end = "$_dep['num']">&nbsp;&nbsp;</for>|-{$_dep.name}</option>
                </volist>
                </select>
                &nbsp;&nbsp;用户组：<select name='gid' class="form-control mr20 w120">
                <option value='-1'>全部</option>
                <volist name="groupList" id="group">
                    <option value='{$group.id}' <eq name='Think.get.gid' value="$group.id">selected</eq>>{$group.name}</option>
                </volist>
                </select>
                <button class="btn btn-primary" type="submit">搜索</button>
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th width="60">序号</th>
                            <th>教研室</th>
                            <th>工号</th>
                            <th>姓名</th>
                            <th>用户组</th>
                            <th>实验室名称</th>
                            <th>最后登录时间</th>
                            <th>最后登录IP地址</th>
                            <th width="75">状态</th>
                            <th width="120">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                     <empty name="list">
                            <tr><td colspan="9" align="center">暂无信息</td></tr>
                        </empty>
                        <volist name="list" id="list">
                            <tr>
                                <td>{$i}</td>
                                <td>{$list.dep_name}</td>
                                <td>{$list.gh}</td>
                                <td>{$list.name}</td>
                                <td>{$list.groupname}</td>
                                <td>{$list.sysxx_name}</td>
                                <td>
                                   <gt name="list.last_login_time" value='0'>{$list.last_login_time|date='Y-m-d H:i', ###}<else />未登录</gt>
                                </td>
                                <td>{$list.last_login_ip|default='未登录'}</td>
                                <eq name="list.id" value="1">
                                   <td class="center"></td>
                                   <td></td>
                                </eq>

                                <eq name="list.id" value="2">
                                    <td class="center">
                                    <button class='btn <eq name="list.status" value="1">btn-primary<else />btn-default</eq> btn-sm setStatus' type="button" data-url='{:U("Admins/setStatus?id=".$list["id"])}' data-status="{$list.status}">
                                    <eq name="list.status" value='1'>启用<else />禁用</eq>
                                    </button>
                                    </td>
                                    <td>
                                    <a class=" btn-sm btn btn-default editText" data-id='{$list.id}'>修改</a>
                                    </td>
                                </eq>

                                <gt name="list.id" value="2">
                                    <td class="center">
                                    <button class='btn <eq name="list.status" value="1">btn-primary<else />btn-default</eq> btn-sm setStatus' type="button" data-url='{:U("Admins/setStatus?id=".$list["id"])}' data-status="{$list.status}"><eq name="list.status" value='1'>启用<else />禁用</eq></button>
                                    </td>
                                    <td>
                                    <a class=" btn-sm btn btn-default editText" data-id='{$list.id}'>修改</a>
                                    <button data-url='{:U("Admins/del?id=".$list["id"])}' class=" btn-sm btn btn-default delBtn" type="button">删除</button>
                                    </td>
                                </gt>
                            </tr>
                        </volist>
                    </tbody>
                </table>
            </div>
            {$page}
        </div>
    </div>
</div>

<div id="myModal" class="modal fade in" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <form action="{:U('Admins/add')}" id="myform" class="form-horizontal" data-callback="_form_defult_callback">
                <div class="modal-header">
                    <button data-dismiss="modal" class="close" type="button">×</button>
                    <h4 class="modal-title">教职工信息</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">姓名：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <input class="form-control required" name="name" maxlength='20'>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">工号：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <input class="form-control required" name="gh" maxlength='20'>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">员工密码：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                          <input type="password" id="pwd" class="form-control required" name="pwd" maxlength='15' minlength='6'>
                          <small class="form_pwd_info">若不修改密码，此处请留空</small>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">确认密码：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                        <input type="password" class="form-control required" equalTo="#pwd" name="pwd2" maxlength='15' minlength='6'>
                            <small class="form_pwd_info">若不修改密码，此处请留空</small>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">性别：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <select name='sex' class="form-control mr20 w120">
                                <option value='男'>男</option>
                                <option value='女'>女</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">教研室：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <select name='dep_id' class="form-control mr20 w200">
                            <option value='-1'>全部</option>
                            <volist name="depList" id="_dep">
                                <option value='{$_dep.id}'>|-{$_dep.name}</option>
                            </volist>
                        </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">实验室：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <select name='sysxx_id' class="form-control mr20 w120">
                                <option value='-1'>全部</option>
                                <volist name="sysxxList" id="_sysxx">
                                    <option value='{$_sysxx.id}'>{$_sysxx.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">选择所属组：<span class="c-red">*</span></label>
                        <div class="col-sm-4 input-group">
                            <select class="form-control" id="gid" name="gid">
                                <volist name='groupList' id='group'>
                                    <option value="{$group.id}">{$group.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-4 input-group">
                        <label class="radio-inline">
                            <input type="radio" value="1" id="status1" name="status" checked>启用
                        </label>
                        <label class="radio-inline">
                            <input type="radio" value="0"  id="status2" name="status">禁用
                        </label>
                        </div>
                    </div>
                </div>
                <input type='hidden' name='id' id="id">
                <div class="modal-footer">
                    <button data-dismiss="modal" class=" btn btn-default" type="button">关闭</button>
                    <button class="btn btn-primary" type="submit">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function(){
    $('.addText').click(function(){
        $('#myform')[0].reset();
        $(".form_pwd_info").hide();
        $('#myModal').modal('show');
    });
    $('.editText').click(function(){
        $('#myform')[0].reset();
        var id = $(this).data('id'); waiting();
        $.get('{:U("Admins/edit")}', {id: id}, function(data){
            complete();
        if(data.status == 1){
            $(".form_pwd_info").show();
             $("input[type='password']").removeClass('required');
            var _get_info = data.info;
            $('#myform input[name="id"]').val(_get_info.id);
            $('#myform input[name="name"]').val(_get_info.name);
            $('#myform input[name="gh"]').val(_get_info.gh);
            $('#myform select[name="gid"]').val(_get_info.gid);
            $('#myform select[name="sex"]').val(_get_info.sex);
            $('#myform select[name="dep_id"]').val(_get_info.dep_id);
            $('#myform select[name="sysxx_id"]').val(_get_info.sysxx_id);
            $("#myform :radio[name=status][value='"+_get_info.status+"']").attr("checked",true);
            $('#myform').attr('action', '{:U("Admins/edit")}');
            $('#myModal').modal('show');
        }else{
            showInfo(data.info);
            setTimeout('_form_defult_callback()', 1600);
        }
     });
       
    });
})
</script>